
//金币道具
module py2Obj {


	export class IceProp extends basicProp {
		//玩家加分
		public pointList: egret.Point[] = [];
		public m_point: number;

		m_fb: any;
		public constructor(world: any, gamePanle: any, romveSkins: any) {
			super(world, gamePanle, romveSkins);
			this.objkind = 400;
		}

		public init() {
			super.init();
		}
		public skinskin: MImage;
		public createMyRigidbody(): p2.Body {
			var world: P2World = this.m_world;
			var skin: MImage = this.createSkin("circle1_png");
			this.skinskin = skin;
			//	var body: p2.Body = world.createBoxBodyShape(skin.width, skin.height, p2.Body.KINEMATIC);
			var body: p2.Body = world.createCircleBodyShape(this.skinskin.width / 4, p2.Body.KINEMATIC);
			body.userData.skin = skin;
			body.userData.data = this;
			body.mass = 0;//质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
			//body.gravityScale=0;
			var shape = body.shapes[0];
			skin.addEventListener(egret.Event.ENTER_FRAME, this.timerFunc1, this);

			//	shape.collisionGroup = 2;//010与001为0，010与110为1
			// shape.collisionMask=2;
			shape.collisionMask = 6;
			// trace(shape.collisionGroup,shape.collisionMask)
			return body;
		}
		public Destroy() {
			var goold = new Array();
			goold = PropManager.twoIce;
			if (goold.length > 0) {
				let length = goold.length
				for (let i = 0; i < length; i++) {
					let jinbi = goold[0];
					goold.splice(0, 1);
					this.m_propManger.removePorp(jinbi);
				}
			}
			else {
				this.m_propManger.removePorp(this);
			}

		}
		public timerFunc1() {     //5555
			// 	 GameControl.GameControlSole.textNumberTextNumber.x=this.skinskin.x-25;
			// 	 GameControl.GameControlSole.textNumberTextNumber.y=this.skinskin.y-80;

			if (GameControl.GameControlSole.Collidetime.shuzi == 0) {
				this.skinskin.scaleX = 1;
				this.skinskin.scaleY = 1;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 1) {
				this.skinskin.scaleX = 1.2;
				this.skinskin.scaleY = 1.2;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 2) {
				this.skinskin.scaleX = 1.4;
				this.skinskin.scaleY = 1.4;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 3) {
				this.skinskin.scaleX = 1.6;
				this.skinskin.scaleY = 1.6;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 4) {
				this.skinskin.scaleX = 1.8;
				this.skinskin.scaleY = 1.8;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 5) {
				this.skinskin.scaleX = 2;
				this.skinskin.scaleY = 2;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 6) {
				this.skinskin.scaleX = 2.2;
				this.skinskin.scaleY = 2.2;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 7) {
				this.skinskin.scaleX = 2.4;
				this.skinskin.scaleY = 2.4;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 8) {
				this.skinskin.scaleX = 2.6;
				this.skinskin.scaleY = 2.6;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 9) {
				this.skinskin.scaleX = 2.8;
				this.skinskin.scaleY = 2.8;
			}
			else if (GameControl.GameControlSole.Collidetime.shuzi == 10) {
				this.skinskin.scaleX = 3;
				this.skinskin.scaleY = 3;
			}

		}

		public getCollision(otherBody: basicObj) {
			super.getCollision(otherBody);
			var cishu: number;
			var objPoint: egret.Point = new egret.Point(this.m_body.position[0] + 20, this.m_body.position[1] + 20);
			// if (cishu < GameControl.GameControlSole.Collidetime.shuzi) {

			GameControl.GameControlSole.goldFrameAnimation(objPoint);
			// 	cishu++;
			// }
			//for (this.cishu = 0; this.cishu < GameControl.GameControlSole.Collidetime.shuzi; this.cishu++) {

			//} 
			//GameControl.GameControlSole.laserResult(this.m_body.position[0], this.m_body.position[1]);
			if (otherBody.objkind == 301 || otherBody.objkind == 103 || otherBody.objkind == 105) {
				this.m_gamePanle.addPoint(this.m_point);
				// if(GameControl.GameControlSole.jiaQiuCount<=0)
				// {
				// 	this.m_fb = <fakeBullet>otherBody;
				//  var bullet = this.m_fb.runEnd();
				// }
				this.m_fb = <fakeBullet>otherBody;
				var bullet = this.m_fb.runEnd();
				this.Destroy();
				return bullet;
			}
			else if (otherBody.objkind == 102 || otherBody.objkind == 104) {
				this.m_gamePanle.addPoint(this.m_point);
				this.m_fb = <fakeBullet>otherBody;
				var bullet = this.m_fb.runEnd2();
				this.Destroy();
				return bullet;
			}

		}

	}
}